#include "c_precompiled.h"
#include "c_local.h"

//TODO: move this somewhere else
void printlog(const char *fmt,...){
	char	message[16384];//shoud be enough
	va_list	argPtr;
	int		len;

	va_start(argPtr, fmt);
	len = vsnprintf(message, sizeof(message), fmt, argPtr);
	va_end(argPtr);
	
	Ogre::String msg=Ogre::String("MESSAGE: ")+message+Ogre::String("\n");
	Ogre::LogManager::getSingleton().logMessage(msg);
}

EngineSystem::EngineSystem(){
	enet_initialize();
	Client::getSingleton().init();
	Server::getSingleton().init(53789);
}
EngineSystem::~EngineSystem(){
	Server::getSingleton().shutdown();
	Client::getSingleton().shutdown();
	enet_deinitialize();
}
void EngineSystem::run(){
	while(true){
		Client::getSingleton().update();
		Server::getSingleton().update();
		if(!Client::getSingleton().isRunning())
			break;
	}
}